import request from 'umi-request';

export async function saveAndUpdatePerformanceRatio(params) {
  return request('/hr-ssc/api/api-admin/performance/saveAndUpdatePerformanceRatio', {
    method: 'POST',
    data: params,
  });
}

export async function getPerformanceRatioById(id) {
  return request('/hr-ssc/api/api-admin/performance/getPerformanceRatioById', {
    method: 'GET',
    params: {id},
  }).then((res) => {
    return res.data;
  });
}

export async function queryPersonalAssessList(params,tabIndex) {
  // return request('/hr-ssc/api/api-admin/salary/getSalaryDistributionPage', {
  //   method: 'get',
  //   params: {
  //     pageNum: params.current,
  //     pageSize: params.pageSize,
  //     ...params
  //   },
  // }).then((res) => {
  //   if (res.flag) {
  //     const data = res.data;
  //     return {
  //       current: data.currPage,
  //       data: data.list,
  //       pageSize: data.pageSize,
  //       success: true,
  //       total: data.totalCount,
  //     };
  //   } else {
  //     return {};
  //   }
  // });
  return {};
}

export async function queryPersonalManageList(params,tabIndex) {
  // return request('/hr-ssc/api/api-admin/salary/getSalaryDistributionPage', {
  //   method: 'get',
  //   params: {
  //     pageNum: params.current,
  //     pageSize: params.pageSize,
  //     ...params
  //   },
  // }).then((res) => {
  //   if (res.flag) {
  //     const data = res.data;
  //     return {
  //       current: data.currPage,
  //       data: data.list,
  //       pageSize: data.pageSize,
  //       success: true,
  //       total: data.totalCount,
  //     };
  //   } else {
  //     return {};
  //   }
  // });
  return {};
}

export async function queryUnitManageList(params,approveStatus) {
  return request('/hr-ssc/api/api-admin/performance/getPerformanceUnitManagementPage', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      approveStatus:approveStatus,
      ...params,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function queryUnitAssessList(params,type) {
  return request('/hr-ssc/api/api-admin/performance/getPerformanceUnitRecordPage', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      type:type,
      ...params,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function deleteUnitManage(id) {
  return request('/hr-ssc/api/api-admin/performance/deletePerformanceUnitManagementById', {
    method: 'delete',
    params: {id},
  }).then((res) => res);
}

export async function saveAndUpdatePerformanceUnitManagement(data) {
  return request('/hr-ssc/api/api-admin/performance/saveAndUpdatePerformanceUnitManagement', {
    method: 'post',
    data:data,
  }).then(res => res);
}

export async function getOrgIdAndYearList(orgIds,assessmentYear) {
  return request('/hr-ssc/api/api-admin/performance/getPerformanceUnitRecordByOrgIdAndYearList', {
    method: 'get',
    params: {
      orgIds:orgIds,
      assessmentYear:assessmentYear
    },
  }).then((res) => {
    if (res.flag)
      return res.data;
    return null;
  });
}

export async function saveAndUpdatePerformanceUnitRecord(data) {
  return request('/hr-ssc/api/api-admin/performance/saveAndUpdatePerformanceUnitRecord', {
    method: 'post',
    data:data,
  }).then(res => res);
}

export async function deletePerformanceUnitRecordById(id) {
  return request('/hr-ssc/api/api-admin/performance/deletePerformanceUnitRecordById', {
    method: 'delete',
    params: {id},
  }).then((res) => res);
}
